// pages/home/home.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active:0,
    interval:3000,
    durataion:500,
    banners:[],
    time: 30 * 60 * 60 * 1000,
    timeData: {},
    goods:[]
  },
  onLoad: function (options) {
    this.getBanners(),
    this.getGoods()
  },
  onChange(){

  },
  onTimeChange(e) {
    this.setData({
      timeData: e.detail,
    });
  },
  getBanners(){
    wx.request({
      url:"http://localhost:3000/api/getbanner",
      success: res=>{
        this.setData({
          banners:res.data.list
        })
        // console.log(res);
      }
    })
  },
  // 获取首页商品数据
  getGoods(){
    wx.request({
      url:"http://localhost:3000/api/getindexgoods",
      success:res=>{
        let list = res.data.list
        list[0].title = "热卖"
        list[1].title = "好货"
        list[2].title = "专场"
        console.log(res)
        this.setData({
          goods: list
        })
      }
    })
  },
  buyNow(evt){
    let id = evt.currentTarget.dataset.id
    console.log("home:",evt);
    wx.navigateTo({
      url: '/pages/detail/detail?id='+id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */




})